*-------------------------------------------------------------------------------
*Project: School Closures
*This code: Submission Package - Tables
*Author: Anelli, Galasso, Griselda
*-------------------------------------------------------------------------------
*Date created 14/05/22
*-------------------------------------------------------------------------------

************
**# TABLES *
************
/* Summary Statistics of Time Spent for Educational Inputs */

preserve

drop if cntr==8 // remove Sweden from this summ stat

tab tot_act 			pandemic
	la variable tot_act "\textbf{Tot. N. of Hours Allocated}"
tab act_class 			pandemic
	la variable act_class "\textbf{Hours of In-person or Online School Lessons} "
tab act_hmwk_superv 	pandemic
	la variable act_hmwk_superv "\textbf{\shortstack{Hours of Supervised Homework \\ (with parents or tutor)}}" 
tab act_hmwk_alone 		pandemic
	la variable act_hmwk_alone "\textbf{Hours of Unsupervised Homework}"
tab act_extracurric		pandemic
	la variable act_extracurric "\textbf{\shortstack{Hours of Extra. Act. \\ (e.g. sport)}}" 
tab act_other			pandemic
	la variable act_other "\textbf{\shortstack{Hours of Other Act. \\ (e.g. play time)}}"

foreach var in tot_act act_class act_hmwk_superv act_hmwk_alone act_extracurric act_other{
	gen `var'_ele	=`var' if schoolkid==2
	gen `var'_lowsec=`var' if schoolkid==3
	gen `var'_uppsec=`var' if schoolkid==4
}
 	la variable  tot_act_ele 			 	"Elementary Students"
 	la variable  tot_act_lowsec  			"Lower Secondary Students"
 	la variable  tot_act_uppsec  			"Upper Secondary Students"
 	la variable  act_class_ele  			"Elementary Students"
 	la variable  act_class_lowsec  			"Lower Secondary Students"
 	la variable  act_class_uppsec  			"Upper Secondary Students"
 	la variable  act_hmwk_superv_ele  		"Elementary Students"
 	la variable  act_hmwk_superv_lowsec  	"Lower Secondary Students"
 	la variable  act_hmwk_superv_uppsec  	"Upper Secondary Students"
 	la variable  act_hmwk_alone_ele  		"Elementary Students"
 	la variable  act_hmwk_alone_lowsec  	"Lower Secondary Students"
 	la variable  act_hmwk_alone_uppsec  	"Upper Secondary Students"
 	la variable  act_extracurric_ele  		"Elementary Students"
 	la variable  act_extracurric_lowsec  	"Lower Secondary Students"
 	la variable  act_extracurric_uppsec  	"Upper Secondary Students"
 	la variable  act_other_ele  			"Elementary Students"
 	la variable  act_other_lowsec  			"Lower Secondary Students"
 	la variable  act_other_uppsec 			"Upper Secondary Students"
	
local vars tot_act tot_act_ele tot_act_lowsec tot_act_uppsec act_class act_class_ele act_class_lowsec act_class_uppsec act_hmwk_superv  act_hmwk_superv_ele act_hmwk_superv_lowsec act_hmwk_superv_uppsec act_hmwk_alone act_hmwk_alone_ele act_hmwk_alone_lowsec act_hmwk_alone_uppsec act_extracurric act_extracurric_ele act_extracurric_lowsec act_extracurric_uppsec act_other act_other_ele act_other_lowsec act_other_uppsec

tempname postMeans
tempfile means
postfile `postMeans' ///
		str100 varname maleMeans femaleMeans diffMeans pMeans using "`means'", replace
foreach v of local vars {
			local name: variable label `v'
			ttest `v', by(pandemic)
			post `postMeans' ("`name'") (r(mu_1)) (r(mu_2)) (r(mu_2)-r(mu_1)) (r(p))
		}
postclose `postMeans'

use `means', clear
format *Means %9.3f
list

listtab * using Table_S3.tex, rstyle(tabular) replace
		
restore